import 'package:built_collection/built_collection.dart';
import 'package:mobile_app/app/domain/helpers/create_dialect_from_asset_one/helper.dart';
import 'package:mobile_app.core/core/domain/entities/asset/asset_dialect.dart';
import 'package:mobile_app.core/core/domain/entities/dialect.dart';

abstract class CreateLexicalItemTranscriptionsFromAssetOnes {
  BuiltMap<Dialect, String> call({
    required BuiltMap<AssetDialect, String> assetTranscriptions,
  });
}

class CreateLexicalItemTranscriptionsFromAssetOnesImpl
    implements CreateLexicalItemTranscriptionsFromAssetOnes {
  const CreateLexicalItemTranscriptionsFromAssetOnesImpl({
    required CreateDialectFromAssetOne createDialectFromAssetOne,
  }) : _createDialectFromAssetOne = createDialectFromAssetOne;

  final CreateDialectFromAssetOne _createDialectFromAssetOne;

  @override
  BuiltMap<Dialect, String> call({
    required BuiltMap<AssetDialect, String> assetTranscriptions,
  }) {
    final transcriptions = assetTranscriptions.map((assetDialect, transcription) {
      final dialect = _createDialectFromAssetOne(
        assetDialect: assetDialect,
      );

      return MapEntry(dialect, transcription);
    }).toMap();

    return transcriptions.build();
  }
}
